<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      xmlns:th="http://www.thymeleaf.org"
      layout:decorator="backstage/layout">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
    <title>活动管理</title>
    
    <style type="text/css">
	#wen_juan input[type="checkbox"],#wen_juan input[type="radio"] {
	margin-top: 8px;
	margin-right: 5px;
	}
	.longcon{
	margin-bottom:10px;
	}
	.dele{
	margin-left:10px;
	}
    </style>
</head>
<body>
<div id="content" layout:fragment="content">
<script type="text/javascript" src="../../../admin/ace/js/fuelux/fuelux.spinner.min.js"></script>
<script type="text/javascript" src="../../../admin/ace/js/ace-elements.min.js"></script>
<script type="text/javascript">

        $(function(){  
        	
			//提交更新
            $("#editActivity").validate( {
                checkStart : true,
                errorElement: 'span',
                errorClass: 'help-inline',
                focusInvalid: false,
                rules : {
                	brandId : {
                        required: true
                    },
                    name : {
                        required: true
                    },
                    startTime : {
                        required: true
                    },
                    endTime : {
                        required: true
                    }
                },
                messages : {
                	brandId : {
                        required : "必须选择"
                    },
                    name : {
                        required : "必须填写"
                    },
                    startTime : {
                        required: "必须填写"
                    },
                    endTime : {
                        required: "必须填写"
                    }
                },
                submitHandler : function(form) {
                	var startTime=$("#s_time").val();
    				var endTime=$("#e_time").val();
    				var start=new Date(startTime.replace("-", "/").replace("-", "/"));
    				var end=new Date(endTime.replace("-", "/").replace("-", "/"));
    				
    				if(start>end){
    					alert("开始时间不能大于结束时间！");
    					return false;
    				}
    				if($("#imgPath_hid").val()==""){
    					if($('#id-input-file-2').val()==""){
    						alert("请选择背景图片！");
    						return false;
    					}
    				}
    				
    				if($("#type_hid").val()=='1'){
    					if($("#edit_quesName1").val()==""){
    						 alert("您的竞猜题目还未填写！");
							 return false;
    					}
    					var num = $("#question_option")[0].children.length;
    					for(var i=1;num>i;i++){
    						 if($("#edit_optName1"+i).val()==""){
    							 alert("您有未填写的竞猜选项！");
    							 return false;
    						 }
    					}
    				} else if($("#type_hid").val()=='2'){
    					var num = $("#wen_juan")[0].children.length;
    					if(num == 1){
    						 alert("您还没有添加问卷题目！");
							 return false;
    					}
    					 for(var i=0;num>i;i++){
    						 if(i>0){
    							 if($("#edit_quesName"+i).val()==""){
    	    						 alert("您的问卷题目还未填写！");
    								 return false;
    	    					 }
    							    if($("#edit_que_div"+i)[0].children[1].children[1].children[0].innerHTML == "打分题"){
    							    }
    								if($("#edit_que_div"+i)[0].children[1].children[1].children[0].innerHTML == "问答题"){
    								}
    								if($("#edit_que_div"+i)[0].children[1].children[1].children[0].innerHTML == "单选题"){
    									var optNum = $("#question_option"+i)[0].children.length;
    									for(var j=0;optNum>j;j++){
    										if(j>0){
    											if($("#edit_optName"+i+""+j).val()==""){
    			    	    						 alert("您的问卷有单选题答案还未填写！");
    			    								 return false;
    			    	    					}
    										}
    									}
    								}
    								if($("#edit_que_div"+i)[0].children[1].children[1].children[0].innerHTML == "多选题"){
    									var optNum = $("#question_option"+i)[0].children.length;
    									for(var j=0;optNum>j;j++){
    										if(j>0){
    											if($("#edit_optName"+i+""+j).val()==""){
   			    	    						 alert("您的问卷有多选题答案还未填写！");
   			    								 return false;
   			    	    					}
    										}
    									}
    								}
    						 }
    					 }	 
    				}

					$("#loadingDiv").show();
                    $("#editActivity").ajaxSubmit(function(date,res,me){
                    	$("#loadingDiv").hide();
                        if(date.suc){
                            alert("保存成功了！");
                            window.location.href = "/activity/list.htm";
                        }else{
                        	alert(date.msg);
                        }
                    });
                },
                highlight: function (e) {
                    $(e).closest('.control-group').removeClass('info').addClass('error');
                }
            });
            
        });
		
		 $(function(){
			 
			 var img=$("#imgPath_hid").val();
			 if(img!=""){
				 $('#id-input-file-2').ace_file_input({
		             no_file: img,
		             btn_choose: 'Choose',
		             btn_change: 'Change',
		             droppable: false,
		             onchange: null,
		             thumbnail: false
		         });
			 }else{
				 $('#id-input-file-2').ace_file_input({
		             no_file: '没有文件 ...',
		             btn_choose: 'Choose',
		             btn_change: 'Change',
		             droppable: false,
		             onchange: null,
		             thumbnail: false
		         });
			 }
		 });
		 
		 function addOption(){
			 var num = $("#question_option")[0].children.length;
			 var div1 = $('<div class="controls"></div>');
			 div1.attr("id","optDiv"+num);
	  		  	
	  		 var input2 = $('<input class="input-xlarge focused" type="text" />');
	  		 input2.attr("id","edit_optName1"+num);
	  		 input2.attr("name","optName1"+num);
	  		 div1.append(input2);
	  		 
	  		 var input3 = $('<input class=" btn btn-info btn-small dele" type="button" value="删除" />');
	  		 input3.attr("onclick","delOption(this.name);");
	  		 input3.attr("name","optDiv"+num);
	  		 div1.append(input3);
	  		 
	  		 $("#question_option").append(div1);
		 }
		 
		 function delOption(id){
			 $("#"+id).remove();
			 var num = $("#question_option")[0].children.length;
			 for(var i=0;num>i;i++){
				 if(i>2){
					 $("#question_option")[0].children[i].id="optDiv"+i;
					 $("#question_option")[0].children[i].children[1].name = "optDiv"+i;
					 $("#question_option")[0].children[i].children[0].id = "edit_optName1"+i;
					 $("#question_option")[0].children[i].children[0].name = "optName1"+i;
				 }
			 }
		 }
     	
     	function addTScore(num){
			 var div1 = $('<div class="control-group"><span class="control-label">题号:</span><div class="controls"><span>'+num+'</span></div></div>');
			// div1.attr("id","queDiv"+num);
			 var div2 = $('<div class="control-group"><span class="control-label">题型:</span><div class="controls"><span>打分题</span></div></div>');
			 
			 var input1 = $('<input type="hidden" value="1" />');
			 input1.attr("name","quesType"+num);
			 div1.append(input1);
			 
			
			 
			 var div3 = $('<div class="control-group"><span class="control-label">题目:</span></div>');
			 
			 var input4 =$('<div class="controls"></div>');
			 div3.append(input4);
			 
			 var input4in = $('<input class="input-xlarge focused" type="text" />');
	  		 input4in.attr("id","edit_quesName"+num);
	  		 input4in.attr("name","quesName"+num);
	  		 input4.append(input4in);
	  		 
	  		 var input2 = $('<div class="control-group"><span class="control-label"></span></div>');
			 
			 var input2in = $('<div class="controls"></div>');
			 input2.append(input2in);
			 
			 var input2inin = $('<input class=" btn btn-info btn-small" type="button" value="删除题目" />');
			 input2inin.attr("onclick","delQues(this.name);");
			 input2inin.attr("name","edit_div"+num);
			 input2in.append(input2inin);
	  		 
	  		 $("#edit_que_div"+num).html(div1);
	  		 $("#edit_que_div"+num).append(div2);
	  		 $("#edit_que_div"+num).append(div3);
	  		 $("#edit_que_div"+num).append(input2);
	  		 
	  		addNext(parseInt(num)+1);
     	}
     	
		function addTAns(num){
			 var div1 = $('<div class="control-group"><span class="control-label">题号:</span><div class="controls"><span>'+num+'</span></div></div>');
		//	 div1.attr("id","queDiv"+num);
			 var div2 = $('<div class="control-group"><span class="control-label">题型:</span><div class="controls"><span>问答题</span></div></div>');
			 
			 var input1 = $('<input type="hidden" value="2" />');
			 input1.attr("name","quesType"+num);
			 div1.append(input1);
			 
			 var div3 = $('<div class="control-group"><span class="control-label">题目:</span></div>');
			 
			 var input4 =$('<div class="controls"></div>');
			 div3.append(input4);
			 
			 var input4in = $('<input class="input-xlarge focused" type="text" />');
	  		 input4in.attr("id","edit_quesName"+num);
	  		 input4in.attr("name","quesName"+num);
	  		 input4.append(input4in);
	  		 
	  		 var input2 = $('<div class="control-group"><span class="control-label"></span></div>');
			 
			 var input2in = $('<div class="controls"></div>');
			 input2.append(input2in);
			 
			 var input2inin = $('<input class=" btn btn-info btn-small" type="button" value="删除题目" />');
			 input2inin.attr("onclick","delQues(this.name);");
			 input2inin.attr("name","edit_div"+num);
			 input2in.append(input2inin);
	  		 
			 $("#edit_que_div"+num).html(div1);
			 $("#edit_que_div"+num).append(div2);
	  		 $("#edit_que_div"+num).append(div3);
	  		 $("#edit_que_div"+num).append(input2);
	  		 
	  		addNext(parseInt(num)+1);

     	}
     	
		function addTOne(num){
			 var div1 = $('<div class="control-group"><span class="control-label">题号:</span><div class="controls"><span>'+num+'</span></div></div>');
	//		 div1.attr("id","queDiv"+num);
	
			 var div2 = $('<div class="control-group"><span class="control-label">题型:</span><div class="controls"><span>单选题</span></div></div>');
			 
			 var input1 = $('<input type="hidden" value="3" />');
			 input1.attr("name","quesType"+num);
			 div1.append(input1);
			 
			 var div3 = $('<div class="control-group"><span class="control-label">题目:</span></div>');
			 
			 var input4 =$('<div class="controls"></div>');
			 div3.append(input4);
			 
			 var input4in = $('<input class="input-xlarge focused" type="text" />');
	  		 input4in.attr("id","edit_quesName"+num);
	  		 input4in.attr("name","quesName"+num);
	  		 input4.append(input4in);
	  		 
	  		 var div5 = $('<div class="control-group"></div>');
	  		 div5.attr("id","question_option"+num);
	  		 
	  		 var span5 = $('<span class="control-label">答案:</span>');
	  		 div5.append(span5);
	  		 
	  		 var div6 = $('<div class="controls longcon"></div>');
	  		 div6.attr("id","optDiv"+num+"1");
	  		 div5.append(div6);
	  		 
	  		 var rad6 = $('<input type="radio" />');
	  		 rad6.attr("name","radio_"+num);
	  		 div6.append(rad6);
	  		 
	  		 var input7 = $('<input class="input-xlarge focused" type="text" />');
	  		 input7.attr("id","edit_optName"+num+"1");
	  		 input7.attr("name","optName"+num+"1");
	  		 div6.append(input7);
	  		 
	  		 var div8 = $('<div class="controls longcon"></div>');
	  		 div8.attr("id","optDiv"+num+"2");
	  		 div5.append(div8);
	  		 
	  		 var rad8 = $('<input type="radio" />');
	  		 rad8.attr("name","radio");
	  		 div8.append(rad8);
	  		 
	  		 var input9 = $('<input class="input-xlarge focused" type="text" />');
	  		 input9.attr("id","edit_optName"+num+"2");
	  		 input9.attr("name","optName"+num+"2");
	  		 div8.append(input9);
	  		 
	  		 var input5 = $('<div class="control-group"><span class="control-label"></span></div>');
			 
			 var input5in = $('<div class="controls"></div>');
			 input5.append(input5in);
	  		 
	  		 var input5inin = $('<input class=" btn btn-info btn-small" type="button" value="新增答案" onclick="addOptionAns(this.name,3);"/>');
	  		 input5inin.attr("name",num);
	  		 input5in.append(input5inin);
	  		 
	  		 var input2 = $('<div class="control-group"><span class="control-label"></span></div>');
			 
			 var input2in = $('<div class="controls"></div>');
			 input2.append(input2in);
			 
			 var input2inin = $('<input class=" btn btn-info btn-small" type="button" value="删除题目" />');
			 input2inin.attr("onclick","delQues(this.name);");
			 input2inin.attr("name","edit_div"+num);
			 input2in.append(input2inin);
			 
	  		 $("#edit_que_div"+num).html(div1);
	  		 $("#edit_que_div"+num).append(div2);
	  		 $("#edit_que_div"+num).append(div3);
	  		 $("#edit_que_div"+num).append(div5);
	  		 $("#edit_que_div"+num).append(input5);
	  		 $("#edit_que_div"+num).append(input2);
	  		 
	  		addNext(parseInt(num)+1);
		}
	
		function addTMore(num){
			var div1 = $('<div class="control-group"><span class="control-label">题号:</span><div class="controls"><span>'+num+'</span></div></div>');
	//		 div1.attr("id","queDiv"+num);
	 		var div2 = $('<div class="control-group"><span class="control-label">题型:</span><div class="controls"><span>多选题</span></div></div>');
			 
			 var input1 = $('<input type="hidden" value="4" />');
			 input1.attr("name","quesType"+num);
			 div1.append(input1);
			 
			 var div3 = $('<div class="control-group"><span class="control-label">题目:</span></div>');
			 
			 var input4 =$('<div class="controls"></div>');
			 div3.append(input4);
			 
			 var input4in = $('<input class="input-xlarge focused" type="text" />');
	  		 input4in.attr("id","edit_quesName"+num);
	  		 input4in.attr("name","quesName"+num);
	  		 input4.append(input4in);
	  		 
	  		 var div5 = $('<div class="control-group"></div>');
	  		 div5.attr("id","question_option"+num);
	  		 
	  		 var span5 = $('<span class="control-label">答案:</span>');
	  		 div5.append(span5);
	  		 
	  		 var div6 = $('<div class="controls longcon"></div>');
	  		 div6.attr("id","optDiv"+num+"1");
	  		 div5.append(div6);
	  		 
	  		 var chex6 = $('<input type="checkbox"/>');
	  		 div6.append(chex6);
	  		 
	  		 var input7 = $('<input class="input-xlarge focused" type="text" />');
	  		 input7.attr("id","edit_optName"+num+"1");
	  		 input7.attr("name","optName"+num+"1");
	  		 div6.append(input7);
	  		 
	  		 var div8 = $('<div class="controls longcon"></div>');
	  		 div8.attr("id","optDiv"+num+"2");
	  		 div5.append(div8);
	  		 
	  		 var chex8 = $('<input type="checkbox"/>');
	  		 div8.append(chex8);
	  		 
	  		 var input9 = $('<input class="input-xlarge focused" type="text" />');
	  		 input9.attr("id","edit_optName"+num+"2");
	  		 input9.attr("name","optName"+num+"2");
	  		 div8.append(input9);
	  		 
	  		 var input5 = $('<div class="control-group"><span class="control-label"></span></div>');
			 
			 var input5in = $('<div class="controls"></div>');
			 input5.append(input5in);
	  		 
	  		 var input5inin = $('<input class=" btn btn-info btn-small" type="button" value="新增答案" onclick="addOptionAns(this.name,4);"/>');
	  		 input5inin.attr("name",num);
	  		 input5in.append(input5inin);
	  		 
	  		 var input2 = $('<div class="control-group"><span class="control-label"></span></div>');
			 
			 var input2in = $('<div class="controls"></div>');
			 input2.append(input2in);
			 
			 var input2inin = $('<input class=" btn btn-info btn-small" type="button" value="删除题目" />');
			 input2inin.attr("onclick","delQues(this.name);");
			 input2inin.attr("name","edit_div"+num);
			 input2in.append(input2inin);
	  		 
	  		 $("#edit_que_div"+num).html(div1);
	  		 $("#edit_que_div"+num).append(div2);
	  		 $("#edit_que_div"+num).append(div3);
	  		 $("#edit_que_div"+num).append(div5);
	  		 $("#edit_que_div"+num).append(input5);
	  		 $("#edit_que_div"+num).append(input2);
	  		 
	  		 addNext(parseInt(num)+1);
		}
		
		function addNext(num){
			if($('#edit_div'+num).size()>0){
				return false;
			}
			 var div1=$('<div style="margin-top:20px;"></div>');
	  		 div1.attr("id","edit_div"+num);
	  		 
	  		 var div1in=$('<div class="tabbable"></div>');
	  		 div1.append(div1in);
	  		
	  		 var div1inin=$('<ul class="nav nav-tabs padding-12 tab-color-blue background-blue"></ul>');
	  		 div1in.append(div1inin);
	  		 
	  		 var input2in=$('<li></li>');
	  		div1inin.append(input2in);
	  		 
	  		 var input2 = $('<a data-toggle="tab" type="button" value="新增打分题">新增打分题</a>');
	  		 input2.attr("onclick","addTScore(this.name)");
	  		 input2.attr("name",num);
	  		input2in.append(input2);
	  		
	  		 var input3in=$('<li></li>');
		  	div1inin.append(input3in);
	  		 
	  		 var input3 = $('<a data-toggle="tab" type="button" value="新增问答题">新增问答题</a>');
	  		 input3.attr("onclick","addTAns(this.name)");
	  		 input3.attr("name",num);
	  		input3in.append(input3);
	  		
	  		var input4in=$('<li></li>');
		  	div1inin.append(input4in);
	  		 
	  		 var input4 = $('<a data-toggle="tab" type="button" value="新增单选题">新增单选题</a>');
	  		 input4.attr("onclick","addTOne(this.name)");
	  		 input4.attr("name",num);
	  		input4in.append(input4);
	  		 
	  		var input5in=$('<li></li>');
		  	div1inin.append(input5in);
	  		
	  		 var input5 = $('<a data-toggle="tab" type="button" value="新增多选题">新增多选题</a>');
	  		 input5.attr("onclick","addTMore(this.name)");
	  		 input5.attr("name",num);
	  		 input5in.append(input5);
	  		 
	  		 var div6=$('<div class="tab-content"></div>');
	  		 div6.attr("id","edit_que_div"+num);
	  		 div1.append(div6);
        	
        	 $('#wen_juan').append(div1);
		}
		
		function addOptionAns(k,type){
			 var num = $("#question_option"+k)[0].children.length;
			 
			 var div6 = $('<div class="controls longcon"></div>');
	  		 div6.attr("id","optDiv"+k+""+num);
	  		 
	  		 if(type == "3"){
	  			 var rad6 = $('<input type="radio" />');
	  			 rad6.attr("name","radio");
		  		 div6.append(rad6);
	  		 } else if(type == "4"){
	  			 var chex6 = $('<input type="checkbox"/>');
		  		 div6.append(chex6);
	  		 }
	  		 
	  		 var input7 = $('<input class="input-xlarge focused" type="text" />');
	  		 input7.attr("id","edit_optName"+k+""+num);
	  		 input7.attr("name","optName"+k+""+num);
	  		 div6.append(input7);
	  		 
	  		 var input3 = $('<input class=" btn btn-info btn-small dele" type="button" value="删除" />');
	  		 input3.attr("onclick","delOptionAns(this);");
	  		 input3.attr("name",num);
	  		 input3.attr("id",k);
	  		 div6.append(input3);
	  		 
	  		 $("#question_option"+k).append(div6);
		}
		
		function delOptionAns(me){
			 var m = me.id;
			 var n = me.name;
			 var num = $("#question_option"+m)[0].children.length;
			 $("#optDiv"+m+""+n).remove();
			 for(var i=0;num-1>i;i++){
				 if(i>2){
					 $("#question_option"+m)[0].children[i].id="optDiv"+m+""+i;
					 $("#optDiv"+m+""+i)[0].children[1].id="edit_optName"+m+""+i;
					 $("#optDiv"+m+""+i)[0].children[1].name="optName"+m+""+i;
					 $("#optDiv"+m+""+i)[0].children[2].id=m;
					 $("#optDiv"+m+""+i)[0].children[2].name=i;
					 /*  $("#question_option")[0].children[i].children[1].name = "optDiv"+i;
					 $("#question_option")[0].children[i].children[1].click = "delOption(this.name);";
					 $("#question_option")[0].children[i].children[0].id = "edit_optName"+i;
					 $("#question_option")[0].children[i].children[0].name = "optName"+i; */
				 }
			 }
		}
		
		function delQues(id){
			 $("#"+id).remove();
			 var num = $("#wen_juan")[0].children.length;
			 for(var i=0;num>i;i++){
				 var j = i+1;
					 $("#wen_juan")[0].children[i].id="edit_div"+j;
					 $("#edit_div"+j).find("li").find("a")[0].name = j;
					 $("#edit_div"+j).find("li").find("a")[1].name = j;
					 $("#edit_div"+j).find("li").find("a")[2].name = j;
					 $("#edit_div"+j).find("li").find("a")[3].name = j;
					 $("#edit_div"+j)[0].children[1].id = "edit_que_div"+j;
					 if(j==num){
						 break;
					 }
					 
			//		 $("#edit_que_div"+j)[0].children[0].id = "queDiv"+j;
					 $("#edit_que_div"+j)[0].children[0].children[1].children[0].innerHTML = j;
					 $("#edit_que_div"+j)[0].children[0].children[2].name = "quesType"+j;
					 
					 $("#edit_que_div"+j)[0].children[2].children[1].children[0].id = "edit_quesName"+j;
					 $("#edit_que_div"+j)[0].children[2].children[1].children[0].name = "quesName"+j;
					    if($("#edit_que_div"+j)[0].children[1].children[1].children[0].innerHTML == "打分题"){
					    	$("#edit_que_div"+j)[0].children[3].children[1].children[0].name = "edit_div"+j;
					    }
						if($("#edit_que_div"+j)[0].children[1].children[1].children[0].innerHTML == "问答题"){
							$("#edit_que_div"+j)[0].children[3].children[1].children[0].name = "edit_div"+j;
						}
						if($("#edit_que_div"+j)[0].children[1].children[1].children[0].innerHTML == "单选题"){
							$("#edit_que_div"+j)[0].children[5].children[1].children[0].name = "edit_div"+j;
							$("#edit_que_div"+j)[0].children[4].children[1].children[0].name = j;
							$("#edit_que_div"+j)[0].children[3].id = "question_option"+j;
							var optNum = $("#question_option"+j)[0].children.length;
							for(var k=0;optNum>k;k++){
								if(k>0){
									$('#question_option'+j)[0].children[k].id = "optDiv"+j+""+k;
									$('#question_option'+j)[0].children[k].children[1].id = "edit_optName"+j+""+k;
									$('#question_option'+j)[0].children[k].children[1].name = "optName"+j+""+k;
									if(k>2){
										$('#question_option'+j)[0].children[k].children[2].id = j;
									}
								}
							}
						}
						if($("#edit_que_div"+j)[0].children[1].children[1].children[0].innerHTML == "多选题"){
							$("#edit_que_div"+j)[0].children[5].children[1].children[0].name = "edit_div"+j;
							$("#edit_que_div"+j)[0].children[4].children[1].children[0].name = j;
							$("#edit_que_div"+j)[0].children[3].id = "question_option"+j;
							var optNum = $("#question_option"+j)[0].children.length;
							for(var k=0;optNum>k;k++){
								if(k>0){
									$('#question_option'+j)[0].children[k].id = "optDiv"+j+""+k;
									$('#question_option'+j)[0].children[k].children[1].id = "edit_optName"+j+""+k;
									$('#question_option'+j)[0].children[k].children[1].name = "optName"+j+""+k;
									if(k>2){
										$('#question_option'+j)[0].children[k].children[2].id = j;
									}
								}
							}
						}
			 	}	 
		}
		
    </script> 
	<div class="box-content">
        <div class="row-fluid sortable">
         <div class="box span12"  >
            <div class="modal-header">
                <span th:if="${activity.id==null}">活动添加 </span><span th:if="${activity.id!=null}">活动编辑 </span>
            </div>
            
            
            <form class="form-horizontal" style="margin: 0" action="/activity/update.json" enctype="multipart/form-data" method="post" id="editActivity">
              	<input id="id" name="id"  type="hidden" th:value="${activity.id}"/>   
              	<input id="imgPath_hid" type="hidden" th:value="${activity.imgPath}"/>
              	<input id="type_hid" type="hidden" th:value="${activity.type}"/>   
                <fieldset>
                    <div class="modal-body" style="max-height:none;">
                   
                    
                    <div class="control-group">
                        <label class="control-label">活动品牌：</label>
                        <div class="controls">
                        	<select name="brandId" id="edit_brandId">
			                    <option value="" >--请选择--</option>
			                    <option th:each="brand:${activityBrandList}" th:value="${brand.id}" th:text="${brand.name}" 
			                    th:selected="${activity.brandId == brand.id}" ></option>
			                 </select>
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label">活动类型：</label>
                        <div class="controls">
                        	<span th:if="${activity.type == '1'}">竞猜问题</span>
                            <span th:if="${activity.type == '2'}">问卷活动</span>
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label">活动状态：</label>
                        <div class="controls" style="margin-top: 5px;">
                            	<input class="input-xlarge focused"  type="radio" value="1" name="status" id="edit_status1" th:checked="${activity.status!='2'}"/>开启	
                            	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            	<input class="input-xlarge focused"  type="radio" value="2" name="status" id="edit_status2" th:checked="${activity.status=='2'}"/>关闭	
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label">活动名称：</label>
                        <div class="controls">
                        	<input class="input-xlarge focused" type="text" th:value="${activity.name}" id="edit_name" name="name" />
                        </div>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label" >活动时间：</label>
                        <div class="controls">
							    <!-- <input size="16" type="text" th:value="${activity.startTime}" name="startTime" id="s_time" readonly="readonly" />
							    <span class="add-on"><i class="icon-remove"></i></span>
							    <span class="add-on"><i class="icon-calendar"></i></span> -->
							    <input type="text" class="time-link-input" readonly="readonly" name="startTime" id="s_time" 
							    		th:value="${activity.startTime}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
							    <span>-</span>
							    <input type="text" class="time-link-input" readonly="readonly" name="endTime" id="e_time" 
							    		th:value="${activity.endTime}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                        </div>
                    </div>
                    
                     <div class="control-group">
                        <label class="control-label">活动背景图：</label>
                        <div class="controls" >
                            <div class="widget-main">
	                        	<input type="file"  id="id-input-file-2" name="file" />
		                    </div>
                        </div>
                        
                        <span th:if="${activity.imgPath != null}">
							 <div class="controls">
	                            <div class="widget-main">
	                                <img th:src="${activity.imgPath}" id="edit_imgShow" style=" height: 120px;"/>
	                            </div>
	                        </div>
						</span>
                    </div>
                    
                    <div class="control-group">
                        <label class="control-label">活动介绍：</label>
                        <div class="controls">
                        	<textarea class="input-xlarge focused" rows="6" style="width: 600px" type="text" th:text="${activity.mark}" id="edit_mark" name="mark" />
                        </div>
                    </div>
                    
                    <span th:if="${activity.type == '1'}">
	                    <div>
	                    	<h3>竞猜问题</h3>
	                    </div>
	                    <span th:if="${not #lists.isEmpty(activityQuestionList)}">
	                    	<div th:each="activityQuestion,indexStat:${activityQuestionList}">
	                    		<div>
			                    	<div class="control-group">
				                        <label class="control-label">竞猜题目：</label>
				                        <div class="controls">
				                        	<input class="input-xlarge focused" type="text" th:id="${'edit_quesName'+indexStat.count}" th:name="${'quesName'+indexStat.count}" th:value="${activityQuestion.question}" />
				                        	<input class=" btn btn-info btn-small" type="button" value="新增选项" onclick="addOption();"/>
				                        </div>
				                    </div>
			                    </div>
			                    <div>
			                    	<div class="control-group" id="question_option">
				                        <label class="control-label">竞猜选项：</label>
					                    <div class="controls" th:each="activityOption,indexStat2:${activityQuestion.activityOptionList}" th:id="${'optDiv'+indexStat.count}">
					                        <input class="input-xlarge focused" type="text" th:id="${'edit_optName'+indexStat.count+''+indexStat2.count}" th:name="${'optName'+indexStat.count+''+indexStat2.count}" th:value="${activityOption.name}" />
					                        <input class=" btn btn-info btn-small dele" type="button" value="删除" th:name="${'optDiv'+indexStat2.count}" onclick="delOption(this.name);" th:if="${indexStat2.count > 2}"/>
					                    </div>
				                    </div>
			                    </div>
	                    	</div>
	                    </span>
	                    <span th:if="${#lists.isEmpty(activityQuestionList)}">
	                    	<div>
	                    		<div>
			                    	<div class="control-group">
				                        <label class="control-label">竞猜题目：</label>
				                        <div class="controls">
				                        	<input class="input-xlarge focused" type="text" id="edit_quesName1" name="quesName1" />
				                        	<input type="hidden" value="0" name="quesType1"/>
				                        	<input class=" btn btn-info btn-small" type="button" value="新增选项" onclick="addOption();"/>
				                        </div>
				                    </div>
			                    </div>
			                    <div>
			                    	<div class="control-group" id="question_option">
				                        <label class="control-label">竞猜选项：</label>
				                        <div class="controls">
				                        	<input class="input-xlarge focused" type="text" id="edit_optName11" name="optName11" />
				                        </div>
				                        <div class="controls">
				                        	<input class="input-xlarge focused" type="text" id="edit_optName12" name="optName12" />
				                        </div>
				                    </div>
			                    </div>
	                    	</div>
	                    </span>
	                 </span>    
                    <span th:if="${activity.type == '2'}" >
                    	<div>
	                    	<h3>问卷活动</h3>
	                    </div>
	                    <span th:if="${not #lists.isEmpty(activityQuestionList)}" id="wen_juan">
	                    	<div th:id="${'edit_div'+indexStat.count}" th:each="activityQuestion,indexStat:${activityQuestionList}">
	                    		<div  class="tabbable" >
		                    		<ul class="nav nav-tabs padding-12 tab-color-blue background-blue">
			                    	<li th:class="${activityQuestion.type=='1'?'active':''}"><a data-toggle="tab" type="button" value="新增打分题" th:name="${indexStat.count}" onclick="addTScore(this.name)">新增打分题</a></li>
			                    	<li th:class="${activityQuestion.type=='2'?'active':''}"><a data-toggle="tab" type="button" value="新增问答题" th:name="${indexStat.count}" onclick="addTAns(this.name)">新增问答题</a></li>
			                    	<li th:class="${activityQuestion.type=='3'?'active':''}"><a data-toggle="tab" type="button" value="新增单选题" th:name="${indexStat.count}" onclick="addTOne(this.name)">新增单选题</a></li>
			                    	<li th:class="${activityQuestion.type=='4'?'active':''}"><a data-toggle="tab" type="button" value="新增多选题" th:name="${indexStat.count}" onclick="addTMore(this.name)">新增多选题</a></li>
			                    	</ul>
		                    	</div>
		                    	<div class="tab-content" th:id="${'edit_que_div'+indexStat.count}" th:if="${activityQuestion.type == '1'}">
									<div class="control-group">
										<span class="control-label">题号:</span><div class="controls"><span th:text="${indexStat.count}"></span></div>
										<input type="hidden" value="1" th:name="${'quesType'+indexStat.count}" />
									</div>
									<div class="control-group">
										<span class="control-label">题型:</span><div class="controls"><span>打分题</span></div>
									</div>
										
									<div class="control-group"><span class="control-label">题目:</span>
									<div class="controls"><input th:id="${'edit_quesName'+indexStat.count}" class="input-xlarge focused" type="text" 
											th:name="${'quesName'+indexStat.count}" th:value="${activityQuestion.question}"/></div></div>
									<div class="control-group"><span class="control-label"></span><div class="controls"><input class=" btn btn-info btn-small" type="button" value="删除题目" onclick="delQues(this.name);" th:name="${'edit_div'+indexStat.count}" /></div></div>
		                    	</div>
		                    	<div class="tab-content" th:id="${'edit_que_div'+indexStat.count}" th:if="${activityQuestion.type == '2'}">
									<div class="control-group">
										<span class="control-label">题号:</span><div class="controls"><span th:text="${indexStat.count}"></span></div>
										<input type="hidden" value="2" th:name="${'quesType'+indexStat.count}"/>	
									</div>
									<div class="control-group">
										<span class="control-label">题型:</span><div class="controls"><span>问答题</span></div>
									</div>
									<div class="control-group"><span class="control-label">题目:</span>
									<div class="controls"><input th:id="${'edit_quesName'+indexStat.count}" class="input-xlarge focused" type="text" 
											th:name="${'quesName'+indexStat.count}" th:value="${activityQuestion.question}"/></div></div>
									<div class="control-group"><span class="control-label"></span><div class="controls"><input class=" btn btn-info btn-small" type="button" value="删除题目" onclick="delQues(this.name);" th:name="${'edit_div'+indexStat.count}"/></div></div>
		                    	</div>
		                    	<div class="tab-content" th:id="${'edit_que_div'+indexStat.count}" th:if="${activityQuestion.type == '3'}">
									<div class="control-group">
										<span class="control-label">题号:</span><div class="controls"><span th:text="${indexStat.count}"></span></div>
										<input type="hidden" value="3" th:name="${'quesType'+indexStat.count}"/>	
									</div>
									<div class="control-group">
										<span class="control-label">题型:</span><div class="controls"><span>单选题</span></div>
									</div>
										
									<div class="control-group"><span class="control-label">题目:</span>
									<div class="controls"><input th:id="${'edit_quesName'+indexStat.count}" class="input-xlarge focused" type="text" 
											th:name="${'quesName'+indexStat.count}" th:value="${activityQuestion.question}"/></div></div>
									<div th:id="${'question_option'+indexStat.count}">
										<span class="control-label">答案:</span>
										<div class="controls longcon" th:id="${'optDiv'+indexStat.count+''+indexStat2.count}" th:each="activityOption,indexStat2:${activityQuestion.activityOptionList}">
											<input type="radio" name="radio" />
											<input th:id="${'edit_optName'+indexStat.count+''+indexStat2.count}" class="input-xlarge focused" type="text" 
												th:name="${'optName'+indexStat.count+''+indexStat2.count}" th:value="${activityOption.name}" />
											<input class=" btn btn-info btn-small dele" th:id="${indexStat.count}" type="button" value="删除" onclick="delOptionAns(this);" th:name="${indexStat2.count}"
												th:if="${indexStat2.count > 2}" />
										</div>
									</div>
									<div class="control-group">
										<span class="control-label"></span>
										<div class="controls"><input class=" btn btn-info btn-small" type="button" onclick="addOptionAns(this.name,3);" value="新增答案" th:name="${indexStat.count}" /></div>
									</div>
									<div class="control-group">
										<span class="control-label"></span>
										<div class="controls"><input class=" btn btn-info btn-small" type="button" value="删除题目" onclick="delQues(this.name);" th:name="${'edit_div'+indexStat.count}"/></div>
									</div>
		                    	</div>
		                    	<div class="tab-content" th:id="${'edit_que_div'+indexStat.count}" th:if="${activityQuestion.type == '4'}">
									<div class="control-group">
										<span class="control-label">题号:</span><div class="controls"><span th:text="${indexStat.count}"></span></div>
										<input type="hidden" value="4" th:name="${'quesType'+indexStat.count}"/>
									</div>
									<div class="control-group">
										<span class="control-label">题型:</span><div class="controls"><span>多选题</span></div>
									</div>
									<div class="control-group"><span class="control-label">题目:</span>
									<div class="controls"><input th:id="${'edit_quesName'+indexStat.count}" class="input-xlarge focused" type="text" 
											th:name="${'quesName'+indexStat.count}" th:value="${activityQuestion.question}"/></div></div>
									<div th:id="${'question_option'+indexStat.count}">
										<span class="control-label">答案:</span>
										<div class="controls longcon" th:id="${'optDiv'+indexStat.count+''+indexStat2.count}" th:each="activityOption,indexStat2:${activityQuestion.activityOptionList}">
											<input type="checkbox" />
											<input th:id="${'edit_optName'+indexStat.count+''+indexStat2.count}" class="input-xlarge focused" type="text" 
												th:name="${'optName'+indexStat.count+''+indexStat2.count}" th:value="${activityOption.name}" />
											<input  class=" btn btn-info btn-small dele" th:id="${indexStat.count}" type="button" value="删除" onclick="delOptionAns(this);" th:name="${indexStat2.count}"
												th:if="${indexStat2.count > 2}" />
										</div>
									</div>
									<div class="control-group">
										<span class="control-label"></span>
										<div class="controls"><input class=" btn btn-info btn-small" type="button" onclick="addOptionAns(this.name,4);" value="新增答案" th:name="${indexStat.count}" /></div>
									</div>
									<div class="control-group">
										<span class="control-label"></span>
										<div class="controls"><input class=" btn btn-info btn-small" type="button" value="删除题目" onclick="delQues(this.name);" th:name="${'edit_div'+indexStat.count}"/></div>
									</div>
		                    	</div>
		                    </div>
		                    <div  th:id="${'edit_div'+(activityQuestionList.size()+1)}">
		                    	<div class="tabbable">
		                    	<ul class="nav nav-tabs padding-12 tab-color-blue background-blue">
			                    	<li><a data-toggle="tab" type="button" value="新增打分题" th:name="${activityQuestionList.size()+1}" onclick="addTScore(this.name)" >新增打分题</a></li>
			                    	<li><a data-toggle="tab" type="button" value="新增问答题" th:name="${activityQuestionList.size()+1}" onclick="addTAns(this.name)" >新增问答题</a></li>
			                    	<li><a data-toggle="tab" type="button" value="新增单选题" th:name="${activityQuestionList.size()+1}" onclick="addTOne(this.name)" >新增单选题</a></li>
			                    	<li><a data-toggle="tab" type="button" value="新增多选题" th:name="${activityQuestionList.size()+1}" onclick="addTMore(this.name)" >新增多选题</a></li>
			                     </ul>
			                    </div>
		                    	<div class="tab-content" th:id="${'edit_que_div'+(activityQuestionList.size()+1)}" >
		                    	</div>
			                 </div>
	                    </span>
	                    <span  th:if="${#lists.isEmpty(activityQuestionList)}" id="wen_juan">
	                    	<div id="edit_div1">
	                    		<div class="tabbable">
		                    	<ul class="nav nav-tabs padding-12 tab-color-blue background-blue">
			                    	<li><a data-toggle="tab"  type="button" value="新增打分题" name="1" onclick="addTScore(this.name)" >新增打分题</a></li>
			                    	<li><a data-toggle="tab"  type="button" value="新增问答题" name="1" onclick="addTAns(this.name)" >新增问答题</a></li>
			                    	<li><a data-toggle="tab"  type="button" value="新增单选题" name="1" onclick="addTOne(this.name)" >新增单选题</a></li>
			                    	<li><a data-toggle="tab"  type="button" value="新增多选题" name="1" onclick="addTMore(this.name)" >新增多选题</a></li>
			                    </ul>
			                    </div>
		                    	<div class="tab-content" id="edit_que_div1">
		                    	</div>
		                    </div>
	                    </span>
                    </span>
                    
                    </div>
                    
                    <div class="modal-footer">
                        <input type="submit" class="btn btn-primary btn-small" value="保存"/>
                        <a href="/activity/list.htm" class="btn btn-small" data-dismiss="modal">取消</a>
                    </div>
                </fieldset>
            </form>
   		</div>
    </div>
  </div>           
</div>
</body>
</html>
